var chatServer = global.chat_url + '/notice';
function sendMessage(msg, callback, roomId){
	if(callback && typeof callback != 'function'){
		var tmp = roomId;
		roomId  = callback;
		callback = tmp;
	}
	var socket = io.connect(chatServer);
	socket.off('callback').on('callback', function(data){
		if(callback){
			callback(data);
		}
	});
	if(roomId){
		socket.emit('room notice', roomId, msg);
	}else{
		socket.emit('platform notice', msg);
	}
}

function sendMessageToUser(msg, callback, roomId, userIds){
	if(callback && typeof callback != 'function'){
		var tmp = roomId;
		roomId  = callback;
		callback = tmp;
	}
	var socket = io.connect(chatServer);
	socket.off('callback').on('callback', function(data){
		if(callback){
			if(callback){
				callback(data);
			}
			callback(data);
		}
	});
	if(userIds && userIds.length > 0){
		socket.emit('user notice', roomId, userIds, msg);
	}
}